package ExtendsTest;
/*
分析以下程序存在什么问题？代码臃肿，代码没有得到重复利用
    1.使用继承机制来解决问题 信用卡账户继承银行账户这个大类
    2.A继承B，A称为子类,B称为父类 java中只支持单继承，子类继承父类除构造方法外的所有东西
      支持间接继承
    3.访问父类中的私有属性，不能直接访问，需要get set方法
    4.Object是所有类的父类，java中的类没有显示继承任何类，则默认继承object类
 */
public class ExtendsTest1 {
    public static void main(String[] args){
        Account act1 = new Account("1111",100);
        CreditAccount c1 = new CreditAccount();
        c1.setActno("123");
        c1.setBalance(10);
        c1.setCredit(0.9);
        System.out.println(c1.getActno()+" "+c1.getBalance()+" "+c1.getCredit());
    }
}
//银行账户类
class Account{
    private String actno;
    private double balance;
    public Account(){

    }
    public Account(String actno,double balance){
        this.actno = actno;
        this.balance = balance;
    }

    public String getActno() {
        return actno;
    }

    public void setActno(String actno) {
        this.actno = actno;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
}
//其他类型的账户：信用卡账户
//账号，余额，信誉度
class CreditAccount extends Account{
    /*
    private String actno;
    private double balance;
     */
    private double credit;
    public CreditAccount(){
    }
    /*
    public CreditAccount(String actno,double balance,double credit){
        this.actno = actno;
        this.balance = balance;
        this.credit = credit;
    }

    public String getActno() {
        return actno;
    }

    public void setActno(String actno) {
        this.actno = actno;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
     */
    public double getCredit() {
        return credit;
    }

    public void setCredit(double credit) {
        this.credit = credit;
    }
}